package com.rk.msm.util;

import com.apistd.uni.Uni;
import com.apistd.uni.UniException;
import com.apistd.uni.UniResponse;
import com.apistd.uni.sms.UniMessage;
import com.apistd.uni.sms.UniSMS;

import java.util.HashMap;
import java.util.Map;

/**
 * @author :Rk.
 * @date : 2022/11/23
 */
public class Main {
    public static String ACCESS_KEY_ID = "mei49N1A5rwaznE1132hz7Sx3VGgmxunhf2zcdr3PGiGEGGzM";


    public static void main(String[] args) {
        // 初始化
        Uni.init(ACCESS_KEY_ID);

        // 设置自定义参数 (变量短信)
        Map<String, String> templateData = new HashMap<String, String>();
        templateData.put("code", "5211");

        // 构建信息
        UniMessage message = UniSMS.buildMessage()
                .setTo("18220741604")
                .setSignature("罗林测试")
                .setTemplateId("pub_verif_login_ttl")
                .setTemplateData(templateData);

        // 发送短信
        try {
            UniResponse res = message.send();
            System.out.println(res);
        } catch (UniException e) {
            System.out.println("Error: " + e);
            System.out.println("RequestId: " + e.requestId);
        }
    }
}
